package se.webbzon.boltzmann.battle.round;

import se.webbzon.boltzmann.battle.battleaction.BattleAction;
import se.webbzon.boltzmann.battle.battleaction.BattleActionListener;
import se.webbzon.oschi01.friendly.Friendly;

/** An implementation of a battle action listener used to listen to battle
 * actions caused by battle buffs. **/
@Friendly class BattleRoundBuffActionListener implements BattleActionListener {

	// The battle round associated with this listener
	private final BattleRound round;
	
	// The next buff to cast for the current non-player battle character
	private final int nextBuff;
	
	// Whatever the strategy shoudl be blocked for the current non-player battle character
	private final boolean block;
			
	/*============================================================
	Constructors
	============================================================*/
	
	/** Creates a new buff battle action listener. **/
	@Friendly BattleRoundBuffActionListener(BattleRound round, int nextBuff, boolean block) {
		this.round = round;
		this.nextBuff = nextBuff;
		this.block = block;
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	@Override public void onBegin(BattleAction battleAction) {}

	@Override public void onEnd(BattleAction battleAction) {
		if (!round.checkAndNotifyVictory(true))
			round.continueTurn(round.getCurrentParticipant(), nextBuff+1, block);
	}
	
}